package cn.xzz.pethome.dept.service.impl;

import cn.xzz.pethome.base.util.Pages;
import cn.xzz.pethome.dept.domain.Dept;
import cn.xzz.pethome.dept.mapper.DeptMapper;
import cn.xzz.pethome.dept.query.DeptQuery;
import cn.xzz.pethome.dept.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DeptServiceimpl implements IDeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public Pages<Dept> getrepage(DeptQuery query) {
        Pages<Dept> pages = new Pages<Dept>();
        pages.setCount(deptMapper.findcount(query));
        pages.setList(deptMapper.findAll(query));
        return pages;
    }

    @Override
    public Dept findById(Long id) {
        return deptMapper.findById(id);
    }

    @Transactional
    @Override
    public void adddept(Dept dept) {
        deptMapper.adddept(dept);
    }

    @Transactional
    @Override
    public void updatedept(Dept dept) {
        deptMapper.updatedept(dept);
    }

    @Transactional
    @Override
    public void delete(Long id) {
        deptMapper.delete(id);
    }


}
